Adopt the UIScene life cycle#25643
Draft
crazytonyli wants to merge 8 commits into
Draft
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 32605 | |
| Version | PR #25643 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 72d621e | |
| Installation URL | 6igud9ajpe33o |
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 32605 | |
| Version | PR #25643 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 72d621e | |
| Installation URL | 3cphdgn1hfr6o |
a682e3d to
e578add
Compare
407de0d to
55292c3
Compare
e578add to
5e27133
Compare
27f34f6 to
2053576
Compare
The app opts into the scene life cycle via application(_:configurationForConnecting:options:), which names WordPressSceneDelegate as the scene delegate in one place for all three app targets instead of three copies of a UIApplicationSceneManifest; the scene delegate creates the scene-attached window and forwards every scene callback into the AppDelegate's shared handlers. Window creation moves from willFinishLaunching to the scene-connect phase, and launch-time URL, user-activity, and shortcut payloads arrive through UIScene.ConnectionOptions, routed through the same methods that handle them at runtime, so the launchOptions plumbing is dead and removed. UITestConfigurator splits into a process part that stays in willFinishLaunching (UI-test flags must be parsed before the launch sequence reads them) and a window part applied when the window is created. The unit test host's TestingAppDelegate doesn't implement the scene opt-in, so tests keep the legacy life cycle.
AppAppearance.overrideAppearance() and the Home Screen quick action creation both reach the app's window indirectly (the override style target and the 3D Touch trait check). Under the scene life cycle the window does not exist until the scene connects, so these no-opped when left in willFinishLaunching and runStartupSequence. Move them into showInitialUI alongside the other window-dependent launch steps.
…nnect The system can disconnect the app's scene in the background and reconnect it later in the same process. showInitialUI previously re-ran the full UI bootstrap on every connect: it created a fresh window while the window manager stayed bound to the old one (leaving the new key window empty), re-registered the Apple ID revocation observer, and replaced the authenticator and notice presenter. The bootstrap now runs exactly once; later connects reattach the existing window to the new scene. The window manager's missing-window fatalError is also downgraded to an assertion with a recovery path, since background launches make it reachable for any unguarded UI path.
Under the scene life cycle, background launches (silent push, background URL session wake) run with no UI and no authenticator: both are set up at the first scene connect now. The support-notification handler built UI through the root view coordinator, and the account-changed handler showed sign-in UI and touched WordPressAuthenticator.shared, which fatalErrors before configureWordPressAuthenticator runs. These paths now skip the UI and observer work when the UI has not been built. The guards key on hasConfiguredInitialUI rather than window presence, because the windowManager emergency fallback can create a window while no scene has ever connected.
sceneWillEnterForeground also fires right after the initial scene connect during a cold launch, unlike the legacy applicationWillEnterForeground, which re-ran the Jetpack migration eligibility check and emitted its analytics event twice per launch; the window phase already runs that check via windowManager.showUI(). The feature flag and remote config refresh is not skipped though: for a background-launched process, the launch-time refresh may be hours stale by the time the user first opens the app, and an extra refresh right after a cold launch is harmless.
A notification-tap cold launch reaches handleNotification while the application state is still .background under the scene life cycle: the scene has connected, but the foreground transition hasn't completed. The inactive handler rejected that state, so the background handler swallowed the tap with a silent sync and the app opened without navigating to the tapped notification. The inactive handler now accepts taps in the background state, matching the existing workaround in the authentication notification handler.
2053576 to
72d621e
Compare
5e27133 to
3392e80
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Note
This PR will be merged after #25638